@{
    ViewBag.Title = "系统日志";
}

@section head{
   <style type="text/css">
      body{ margin:20px; font-size:14px;}
      .line{ line-height:28px;}
      .file { width:400px;display:block; float:left; }
      .parent{ padding-bottom:10px; margin-bottom:10px; border-bottom:1px solid #ccc;}
   </style>
}
@section body{
<body>
   @{
       string path=ViewBag.Path;
       string fullPath=ViewBag.BasePath + path;
       string parentPath=System.IO.Directory.GetParent(fullPath).FullName;
       <div class="parent"><a href="?path=@(parentPath.Length>ViewBag.BasePath.Length?parentPath.Substring(ViewBag.BasePath.Length):"")">@(string.IsNullOrEmpty(path) ? "\\" : path)</a></div>
       if (System.IO.File.Exists(fullPath))
       {
           var log = System.IO.File.ReadAllText(fullPath);
           log = Html.Encode(log);
           log = log.Replace("\r\n", "<br/>");
           @Html.Raw(log);
       }
       else if (System.IO.Directory.Exists(fullPath))
       {
           foreach (var dirname in System.IO.Directory.GetDirectories(fullPath))
           {
               var dir = new System.IO.DirectoryInfo(dirname);
               <div class="line">
                   <a class="file" href="?path=@dirname.Substring(ViewBag.BasePath.Length)">@dir.Name</a>
                   <span class="createtime">@dir.CreationTime.ToString()</span>
               </div>
           }
           foreach (var filename in System.IO.Directory.GetFiles(fullPath))
           {
               var file = new System.IO.FileInfo(filename);
               <div class="line">
                   <a class="file" href="?path=@filename.Substring(ViewBag.BasePath.Length)">@file.Name</a>
                   <span class="createtime">@file.CreationTime.ToString()</span>
               </div>
           }
       }
       else
       {
           Response.Redirect(OA.UI.Utils.GetUrlParames(Url.Action("Error", "Home"), "Title,Message", "错误", "访问的日志不存在"));
       }
   }
</body>
}